<?php

require_once 'Zend/View/Helper/Abstract.php';

class Core_View_Helper_Navigation_SitemapRenderer extends Core_View_Helper_Navigation_Abstract
{
    protected $_attribs = array(
        'indent'               => 4,
        'maxDepth'             => null,
        'minDepth'             => null,
        'formatOutput'         => false,
        'useSchemaValidation'  => false,
        'useSitemapValidators' => true,
        'useXmlDeclaration'    => true,
    );
    protected $_booleanValues = array('formatOutput', 'useSchemaValidation', 'useSitemapValidators', 'useXmlDeclaration');

    public function sitemapRenderer($parentId = 0, $attribs = array())
    {
        if (!Zend_Registry::isRegistered('Zend_Navigation')) {
            // needed to register Navigation into Zend_Registry
            $menu = new Core_Menu($parentId);
        }
        $this->_setAttribs($attribs);

        // render sitemap
        return $this->view->navigation()->sitemap()
            ->setIndent($this->_getAttrib('indent'))
            ->setMaxDepth($this->_getAttrib('maxDepth'))
            ->setMinDepth($this->_getAttrib('minDepth'))
            ->setFormatOutput($this->_getAttrib('formatOutput'))
            ->setUseSchemaValidation($this->_getAttrib('useSchemaValidation'))
            ->setUseSitemapValidators($this->_getAttrib('useSitemapValidators'))
            ->setUseXmlDeclaration($this->_getAttrib('useXmlDeclaration'))
            ->render();
    }
}